#include "graph.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 205;
namespace fvv {
	int g[MAXN][MAXN];
	int mat[MAXN][MAXN], bk[MAXN][MAXN], rec[MAXN][MAXN];
	int deg[MAXN]; int cur;
	int dfs(int f) {
		int u = ++cur;
		deg[u] = NumberOfRoads();
		for (int i = 1; i <= deg[u]; i++) if (i != f) {
			Move(i, 2); bk[u][i] = LastRoad(); mat[u][i] = Color();
			if (Color() == 2) Move(bk[u][i], 2);
			else if (Color() == 3) Move(bk[u][i], 3);
			else {rec[u][i] = dfs(bk[u][i]); Move(bk[u][i], 3);}
		}
		return u;
	}
	int PW;
	void recol(int u, int f) {
		for (int i = 1; i <= deg[u]; i++) if (i != f) {
			if (mat[u][i] == 2) {
				Move(i, u / PW % 3 + 1);
				rec[u][i] += PW * (Color() - 1);
				Move(bk[u][i], Color());
			}
			else if (mat[u][i] == 1) {
				Move(i, u / PW % 3 + 1);
				recol(rec[u][i], bk[u][i]);
				Move(bk[u][i], rec[u][i] / PW % 3 + 1);
			}
		}
	}
	int ret[MAXN];
	void Inspect(int R) {
		int rt = dfs(0);
		PW = 1; for (int _ = 0; _ < 5; _++, PW *= 3) recol(rt, 0);
		memset(g, 0x3f, sizeof g); for (int i = 1; i <= cur; i++) g[i][i] = 0;
		int ecnt = 0;
		for (int i = 1; i <= cur; i++) for (int j = 1; j <= deg[i]; j++) {
			if (rec[i][j]) g[i][rec[i][j]] = g[rec[i][j]][i] = 1, ecnt++;
		}
		fprintf(stderr, "%d\n", ecnt);
		for (int k = 1; k <= cur; k++) {
			for (int i = 1; i <= cur; i++) for (int j = 1; j <= cur; j++) {
				g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
			}
		}
		for (int i = 1; i <= cur; i++) for (int j = i + 1; j <= cur; j++) {
			if (g[i][j] < 0x3f3f3f3f) ret[g[i][j]]++;
		}
		for (int i = 1; i <= R; i++) Answer(i, ret[i]);
	}
}
void Inspect(int R) {fvv::Inspect(R);}
